package com.mc.servlet;

import com.mc.bean.Teacher;
import com.mc.service.TeacherService;
import com.mc.service.impl.TeacherServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Description 教师列表控制器
 * @author wangcf
 * @date 2023/2/14 15:04
 * @version 1.0
 */
@WebServlet("/teacherlist.action")
public class TeacherListServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        TeacherService teacherService=new TeacherServiceImpl();
        List<Teacher> teacherList=teacherService.findAll();
        req.setAttribute("teacherlist",teacherList);
        req.getRequestDispatcher("teacherlist.jsp").forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
